<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>If var [not] between LowerBound and UpperBound</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>If var [not] between LowerBound and UpperBound</h1>

<p>Checks whether a <a href="../Variables.htm">variable's</a> contents are numerically or alphabetically between two values (inclusive).</p>

<pre class="Syntax">if <i>Var</i> between <i>LowerBound</i> and <i>UpperBound</i>
if <i>Var</i> not between <i>LowerBound</i> and <i>UpperBound</i></pre>
<h3>Parameters</h3>
<dl>

  <dt>Var</dt>
  <dd><p>The <a href="../Variables.htm">variable</a> name whose contents will be checked.</p></dd>

  <dt>LowerBound</dt>
  <dd><p>To be within the specified range, <em>Var</em> must be greater than or equal to this string, number, or variable reference.</p></dd>

  <dt>UpperBound</dt>
  <dd><p>To be within the specified range, <em>Var</em> must be less than or equal to this string, number, or variable reference.</p></dd>

</dl>

<h3>Remarks</h3>
<p>If all three of the parameters are purely numeric, they will be compared as numbers rather than as strings. Otherwise, they will be compared alphabetically as strings (that is, alphabetical order will determine whether <em>Var</em> is within the specified range). In that case, <code><a href="StringCaseSense.htm">StringCaseSense</a> On</code> can be used to make the comparison case sensitive.</p>
<p><strong>The operators &quot;between&quot;, &quot;is&quot;, &quot;in&quot;, and &quot;contains&quot; are not supported in <a href="../Variables.htm#Expressions">expressions</a>.</strong></p>
<h3>Related</h3>
<p><a href="IfEqual.htm">IfEqual/Greater/Less</a>, <a href="IfIn.htm">if var in/contains MatchList</a>, <a href="IfIs.htm">if var is type</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringCaseSense.htm">StringCaseSense</a>, <a href="EnvAdd.htm">EnvAdd</a><a href="Block.htm">, Blocks</a>, <a href="Else.htm">Else</a></p>
<h3>Example</h3>
<pre class="NoIndent">if var between 1 and 5
    MsgBox, %var% is in the range 1 to 5, inclusive.

if var <strong>not</strong> between 0.0 and 1.0
    MsgBox %var% is not in the range 0.0 to 1.0, inclusive.

if var between %VarLow% and %VarHigh%
    MsgBox %var% is between %VarLow% and %VarHigh%.

if var between blue and red
    MsgBox %var% is alphabetically between the words blue and red.

LowerLimit = 1
UpperLimit = 10
InputBox, UserInput, Enter a number between %LowerLimit% and %UpperLimit%
if UserInput not between %LowerLimit% and %UpperLimit%
    MsgBox Your input is not within the valid range.</pre>

</body>
</html>
